{% extends 'layout/basic.html' %}

{% block title %}
    用户短信登录
{% endblock %}


{% block css %}
    {% load static %}
    <link rel="stylesheet" href="{% static 'css/account.css' %}">
{% endblock %}


{% block content %}
    <div class="account">
        <div class="title">用户登录</div>


        <form action="" style="width: 320px; margin: auto" id="regForm" method="post">
            {% csrf_token %}
            {% for i in form %}
                {% if i.label == '验证码' %}
                    <div class="form-group">
                        <label for="{{ i.id_for_label }}">
                            {{ i.label }}:
                        </label>
                        <div class="clearfix">
                            <div class="col-md-6"
                                 style="padding-left: 0">{{ i }}<span style="color: red">{{ i.errors.0 }}</span>
                            </div>
                            <div class="col-md-6 "><img src="{% url 'image_code' %}" title="点击更换图片" id="imageCode" alt=""></div>
                        </div>
                    </div>
                {% else %}
                    {% if i.label == '用户名' %}
                        <div class="form-group">
                        <label for="{{ i.id_for_label }}">
                            {{ i.label }}:
                        </label>
                        {{ i }} <span style="color: red">{{ error.name }}</span>
                        </div>
                        {% else %}
                            <div class="form-group">
                        <label for="{{ i.id_for_label }}">
                            {{ i.label }}:
                        </label>
                        {{ i }} <span style="color: red">{{ error.pwd }}</span>
                    </div>
                    {% endif %}
                {% endif %}

            {% endfor %}
            <div class="checkbox">
                <div style="float: right">
                    <a href="{% url 'login_sms'%}" style="text-decoration: none">短信登陆？</a>
                </div>
            </div>
            <div class="row">
                <div class="col-xs-3">
                    <button type="submit" class="btn btn-primary" id="b2">登 录
                    </button>
                </div>
            </div>
        </form>
    </div>
{% endblock %}

{% block js %}
    <script>
        $('#imageCode').click(function () {
            var oldSrc = $(this).attr('src');
            $(this).attr('src', oldSrc+'?')
        });

    </script>
{% endblock %}